#pragma once
#include "stdafx.h"
//-------------------------------------------------------------------------------------------------
//ImageProcStepLibAuto.h  - Collection of Image Processing Functions (Steps) within a single ImageProcStep libarary          
//-------------------------------------------------------------------------------------------------
//FreeBSD License
//Copyright 2012 Will Stott All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are
//permitted provided that the following conditions are met:
//
//   1. Redistributions of source code must retain the above copyright notice, this list of
//      conditions and the following disclaimer.
//
//   2. Redistributions in binary form must reproduce the above copyright notice, this list
//      of conditions and the following disclaimer in the documentation and/or other materials
//      provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY Will Stott ``AS IS'' AND ANY EXPRESS OR IMPLIED
//WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Will Stott OR
//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
//ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
//ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//The views and conclusions contained in the software and documentation are those of the
//authors and should not be interpreted as representing official policies, either expressed
//or implied, of Will Stott.
//
//----Authors--------------------------------------------------------------------------------------
//created by: will.stott@ucl.ac.uk Feb 2012
//
//----Comments-------------------------------------------------------------------------------------
//
//	This class is a composite in ImageProcStepLib as well as corresponding classes in ImageProcStep*Lib
//-------------------------------------------------------------------------------------------------
#ifdef PLUGINICPROCSTEPS_EXPORTS
#define PLUGINICPROCSTEPS_API __declspec(dllexport)
#else
#define PLUGINICPROCSTEPS_API __declspec(dllimport)
#endif

#include <string>
#include <vector>

#include "IImageProcFn.h"


class PLUGINICPROCSTEPS_API ImageProcStepLibAuto
{
public:
	static const char * const attribImageDllDir;

	static const char * const BadIefPathFile;
	static const char * const BadDllName;
	static const char * const BadDllPathFile;
	static const char * const BadDllVersion;
	static const char * const BadDllPath;
	static const char * const BadInfo;

	static const int	ImageProcStepLibAuto::InterfaceVersion = 1;		//increment this if there is any change to ImageProcStepLibAuto, or ProcParams
	static const int	ImageProcStepLibAuto::BadDllInterface = -1;
	static const int	ImageProcStepLibAuto::NotFound = -1;

public:
	ImageProcStepLibAuto(void);
	virtual ~ImageProcStepLibAuto(void);

	bool				SaveLibFunctionDefsToXml(const wchar_t *PathFileNameExistingIef, const wchar_t *ImageProcStepLibDirwStr );		//write the LibApi to IEF as a set of steps - this gives a starting point for developing the IEF

	bool				AddFunction(IImageProcFn *proc);	//no need to call Validate() after invoking AddFunction()
	int					GetFunctionCount();
	IImageProcFn *		GetFunction(int position);
	IImageProcFn *		GetFunction(const char *FnName);
	bool				ClearAllFunctions();

	virtual bool		IsValid() { return ((_error == false) ? true : false); }
	bool				Validate();
	bool				ValidateDetails();

											//call Validate() after invoking any Setter
	void				SetLibNameVersion(const char *name, const char *version, int interfaceVersionNo) {_Name = name,  _Version = version, _IVer = interfaceVersionNo, _error = true; }
	void				SetName(const char *name) { _Name = name, _error = true; }
	const char *        GetName() { return _Name.c_str(); }											//return value even if it is invalid
	void				SetVersion(const char *version) { _Version = version, _error = true; }
	const char *        GetVersion() { return _Version.c_str(); }									//return value even if it is invalid
	void				SetIVersion(int interfaceVersionNo) { _IVer = interfaceVersionNo, _error = true; }
	int					GetIVersion() { return _IVer; }												//return value even if it is invalid

	void				SetLibOwnerDetails(const char *author, const char *copyright, const char *supportSite){ _Author = author, _Copyright = copyright,  _SupportSite = supportSite, _error = true; }
	void				SetCopyright(const char *copyright){ _Copyright = copyright, _error = true; }
	const char *		GetCopyright(){ return _Copyright.c_str(); }								//return value even if it is invalid
	void				SetSupportSite(const char *supportSite){ _SupportSite = supportSite, _error = true; }
	const char *		GetSupportSite(){ return _SupportSite.c_str(); }							//return value even if it is invalid
	void				SetAuthor(const char *author){_Author = author, _error = true; }
	const char *		GetAuthor(){ return _Author.c_str(); }										//return value even if it is invalid

	void				SetLibDescription(const char *description){ _Description = description, _error = true; }
	const char *		GetDescription(){ return _Description.c_str(); }							//return value even if it is invalid

private:
	int					GetFnPosition(const char *FnName);
	
private:
	bool				_error;
	char			   *_pStrFilePathNameBuffer;
	int					_IVer;
#pragma warning(disable:4251)
	std::string					_Name;
	std::string					_Version;
	std::string					_Description;
	std::string					_Author;
	std::string					_Copyright;
	std::string					_SupportSite;
	std::vector<IImageProcFn *>	_Procs;	
#pragma warning(default:4251)

};


//-------------------------------------------------------------------------------------------------
//			E N D   O F   F I L E
//-------------------------------------------------------------------------------------------------